home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with a for loop
- Date: 2 Mar 1996 05:17:20 GMT
- Organization: Nando.net Public Access
- Message-ID: <4h8ll0$9ko@castle.nando.net>
- References: <4h8g0l$1ot@nic.umass.edu>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: vyger117.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4h8g0l$1ot@nic.umass.edu>, ksexton@wilde.oit.umass.edu (Kevin M Sexton) writes:
- >Hi.
- >I was doing a project for one of my classes and I came across a rather
- >odd bug in part of the code. I initially had the following:
- >for ( i = 0; WL[i] != NULL, i <= 10; i++ )
-
- There are two potential problems here. "WL[i] != NULL" is only useful for
- its side effects (remember that "expL, expR" is evaluated left to right
- and has the same type and value as expR) and WL[11] may be out of
- bounds. Try the following:
-
- for ( i = 0; i < 11 && WL[i]; i++ )
-
- <c++ stuff snipped>
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-
-